# conding = utf-8
from selenium.webdriver import ActionChains, Keys

from pages.page import Page
from pages.xgz.role import *


class Role(Page):

    # 查询UI测试
    def open_admin(self):
        '''
        打开管理员UI，如果已经打开则不会执行单击动作
        :return:
        '''
        if self.display(leftmenu) is False:
            self.click(leftmenu_sys)
        self.click(leftmenu)

    ##查询输入第一个框
    def role_addc(self,value):
        self.send_keys(role_add,value)

    #单击重置
    def reset_selectc(self):
        self.click(reset_select)

    #点击查询
    def check_selectc(self):
        self.click(check_select)

    #输入第二个框
    def two_selectc(self,value):
        self.send_keys(two_select,value)

    #查询断言
    def query_select(self):
        return self.is_exists(query_select)


    #新增
    def newly_addedc(self):
        self.click(newly_added)

    #输入第一个框
    def first_added(self,value):
        self.send_keys(first_added,value)

    #第二个输入框
    def the_added(self):
        self.click(the_added)
        actions = ActionChains(self.driver)  # 定义动作链
        actions.send_keys(Keys.DOWN)  # 下键
        actions.send_keys(Keys.ENTER)  # 回车键
        actions.perform()

    #第三个输入框
    def third_added(self):
        self.click(third_added)
        actions = ActionChains(self.driver)  # 定义动作链
        actions.send_keys(Keys.DOWN)  # 下键
        actions.send_keys(Keys.ENTER)  # 回车键
        actions.perform()

    #第四个
    def the_one_added(self,value):
        self.send_keys(the_one_added,value)

    #第五个
    def the_fifth_one(self,value):
        self.send_keys(the_fifth_one,value)

    #点击确定
    def sure_added(self):
        self.click(sure_added)

    #取消
    def cancel_added(self):
        self.click(cancel_added)

    #保存角色名称
    def first_addedct(self):
        return self.get_input_value(first_added)

    #刷新页面
    def windowsreset(self):
        self.driver.refresh()

    #结果
    def result_added(self):
        return self.text(result_added)


    #批量操作
    #打钩
    def tick_batchc(self):
        self.click(tick_batch)

    #批量操作
    def operate_batch(self):
        self.click(operate_batch)

    #禁用
    def disable_batch(self):
        self.click(disable_batch)

    #启用
    def enable_batch(self):
        self.click(enable_batch)

    #确定
    def sure_batch(self):
        self.click(sure_batch)


    #分配功能
    def allocation_function(self):
        self.click(allocation_function)

    #选择树操作
    def operation_function(self):
        self.click(operation_function)

    #取消全选
    def cancel_function(self):
        self.click(cancel_function)

    #选择销售管理
    def sale_function(self):
        self.click(sale_function)

    #点击确定
    def sure_function(self):
        self.click(sure_function)

    #点击里面的确定
    def sure_functions(self):
        self.click(sure_functions)

    #编辑——全选
    def edit_functions(self):
        self.click(edit_functions)

    ##全选——审核
    def toexamine_functions(self):
        self.click(toexamine_functions)

    # 全选——反审核
    def antiaudit_functions(self):
        self.click(antiaudit_functions)

    #确定
    def sures_functions(self):
        self.click(sures_functions)

    #编辑
    def edit_edit(self):
        self.click(edit_edit)

    #输入角色名称
    def first_edit(self,value):
        self.send_keys(first_edit,value)

    #取消
    def cancel_editing(self):
        self.click(cancel_editing)

    #保存角色名称
    def first_editc(self):
        return self.get_input_value(first_edit)

    #结果
    def assertion_edit(self):
        return self.text(assertion_edit)

    #确定
    def sure_edit(self):
        self.click(sure_edit)



    #删除
    def delete_delete(self):
        self.click(delete_delete)

    #点击确定
    def click_delect(self):
        self.click(click_delect)

    #删除的断言
    def assertion_delect(self):
        return self.text(click_delect)

